<?php
	session_start();
	if (isset($_GET['exit'])) {
		session_destroy();
		header("Location: ". $_SERVER['PHP_SELF']);
	}
	require "../core/config.php";
	require "../core/function.php";
	
	if (isset($_SESSION['admin'])) {
		list($name, $pass) = $_SESSION['admin'];

		if (!is_admin($name, $pass)) {
			header("Location: auth.php");
			exit;
		}
	}  else {
		header("Location: auth.php");
		exit;
	}

	$page = '';

	if (isset($_GET['p']))
		$page = $_GET['p'];


	require "includes/header.php";
	main_add($_POST, $_FILES);

	switch ($page) {
		case 'goods':
			include "includes/goods.php";
			break;
		case 'add_goods':
			include "includes/add_goods.php";
			break;
		case 'edit_goods':
			include "includes/edit_goods.php";
			break;
		case 'add_cat':
			include "includes/add_cat.php";
			break;
		case 'view_order':
			include "includes/view_order.php";
			break;
		case 'no_process_order':
			include "includes/no_process_order.php";
			break;
		case 'process_order':
			include "includes/process_order.php";
			break;
		case 'news':
			include "includes/news.php";
			break;
		case 'add_news':
			include "includes/add_news.php";
			break;
		case 'del_news':
			include "includes/del_news.php";
			break;
		default:
			include "includes/content.php";
			break;
	}

	require "includes/footer.php";
	
	mysql_close($db_name);

?>
